package uapp.configuration;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;

import uapp.Application;
import uapp.Page;

public class ApplicationConfig {

	private String id;
	private String name;
	private String resource;
	private String description;
	private List<PageConfig> pages;

	@XmlAttribute(name = "id", required = true)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@XmlAttribute(name = "name", required = true)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@XmlAttribute(name = "resource", required = false)
	public String getResource() {
		return resource;
	}

	public void setResource(String resource) {
		this.resource = resource;
	}

	@XmlAttribute(name = "description", required = false)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@XmlElement(name = "page", required = true)
	public List<PageConfig> getPages() {
		return pages;
	}

	public void setPages(List<PageConfig> pages) {
		this.pages = pages;
	}

	public Application getInstance() {
		Application app = new Application();
		app.setId(getId());
		app.setName(getName());
		app.setDescription(getDescription());
		for(PageConfig config : getPages()){
			app.getPages().add(config.getInstance());
		}
		return app;
	}
}
